#pragma once
#include <IceUtil\Shared.h>
#include <IceUtil\Handle.h>
#include <IceUtil\Mutex.h>
#include <Ice\Config.h>



namespace Xts
{
	namespace Util
	{
		class XSerialGenerator : public ::IceUtil::Shared
		{
		public:
			XSerialGenerator(void);
			XSerialGenerator(const ::Ice::Long& startNo, const ::std::string& prefix);
			~XSerialGenerator(void);

			::Ice::Long SerialNum();
			::std::string SerialStr();

			::Ice::Long TreadSafeSerialNum();
			::std::string TreadSafeSerialStr();

		private:
			const ::Ice::Long x_startNum;
			const ::std::string x_prefix;
			::Ice::Long x_accmValue;			
			::IceUtil::Mutex x_mutex;
		};
		typedef ::IceUtil::Handle<XSerialGenerator> XSerialGeneratorPtr;
	}
}


